package com.wk.webview.client

import android.graphics.Bitmap
import android.util.Log
import android.webkit.WebView
import android.webkit.WebViewClient

class MyWebViewClient(val callback: MyViewClientCallback?) : WebViewClient() {

    override fun onPageFinished(view: WebView?, url: String?) {
        callback?.onPageFinished(url) ?: Log.e(
            Companion.TAG,
            "onPageFinished: webViewClient == null"
        )
    }

    override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
        callback?.onPageStarted(url) ?: Log.e(Companion.TAG, "onPageStarted: webViewClient == null")
    }

    interface MyViewClientCallback {
        fun onPageStarted(url: String?)
        fun onPageFinished(url: String?)
    }

    companion object {
        private const val TAG = "MyWebViewClient"
    }
}